import {UrlUtil} from "./UrlUtil";
import * as $ from 'jquery';
/**
 * Created by yananliu on 2017/11/15.
 */
export class GlobalUtil{

    public static getWindow(global:any):any{
        //搞一下
        return global;
    }

    public static isInWX() : boolean{
        const ua = window.navigator.userAgent.toLowerCase();
        return /micromessenger/.test(ua);
    }

    public static isInAliPay():boolean{
        const ua = window.navigator.userAgent.toLowerCase();
        return /alipayclient/.test(ua);
    }

    public static isInMobile():boolean{

        const vua=navigator.userAgent.toLowerCase();
        return (vua.indexOf("iphone os")>0)||(vua.indexOf("midp")>0)||(vua.indexOf("rv:1.2.3.4")>0)||(vua.indexOf("ucweb")>0)||((vua.indexOf("android")>0)&&(vua.indexOf("mi-pad")<0)&&(vua.indexOf("huaweimediapad")<0))||(vua.indexOf("windows ce")>0)||(vua.indexOf("windows mobile")>0)||(vua.indexOf("iemobile")>0)||(vua.indexOf("wpdesktop")>0);

    }

    public static isInUnionPay():boolean{
        return UrlUtil.readURLParam('terminal')  === '4';
    }

}

//此处暴露jquery为全局变量，外部碎片会用到
GlobalUtil.getWindow(window).$ = $;